package guanchazhe;

import java.util.ArrayList;
import java.util.List;

public class CountSubject implements Subject {

	private List<Observer> obServerList;
	
	private Money money;
	
	public CountSubject() {
		obServerList = new ArrayList<>();
		money = new Money();
		
	}
	
	@Override
	public void addObserver(Observer observer) {
		obServerList.add(observer);
	}

	@Override
	public void delObserver(Observer observer) {
		obServerList.remove(observer);
	}

	@Override
	public void noticeObserver() {
		money.setMoney(20);
		money.setName("jack");
		//obServerList.stream().forEach(Observer -> Observer.update(this));
		for (Observer observer : obServerList) {
			observer.update(money);
		}
	}
	

	



}
